<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img id="logo" src="" alt="">
    <script>
        let logo = document.getElementById('logo');
        logo.addEventListener('load', function (e) {
            console.log('Logo has been loaded!');
        });
        logo.src = "https://tutorial.javascript.ac.cn/wp-content/uploads/2020/02/favicon-300x300.png";
    </script>

    <img id="logo1" src="https://tutorial.javascript.ac.cn/wp-content/uploads/2020/02/favicon-300x300.png"
        onload="console.log('logo1 loaded')"></img>

    <script>
        window.addEventListener('load', function () {
            console.log('window loaded');
            let logo2 = document.createElement('img');
            logo2.addEventListener('load', function () {
                console.log('logo1 loaded');
            });
            document.body.appendChild(logo2);
            logo2.id = "logo2";
            logo2.src = 'https://tutorial.javascript.ac.cn/wp-content/uploads/2020/02/favicon-300x300.png'
            logo2.alt = 'logo1';
        });
    </script>
</body>

</html>